package Tetris;

import javax.smartcardio.TerminalFactory;

//一个小方块
public class Test{//测试字母  测谁就new谁
    public static void main(String[] args) {
        O o=new O(4,4);
        o.printInfo();
    }

}

class Cell{
    int row;//y
    int col;//x
    public Cell(int row, int col) {//赋值
        this.row = row;
        this.col = col;
    }
    //自我描述
    public void printInfo(){
        System.out.println(this.row+","+this.col);
    }

}


class T extends Tetromino{

    public T(int n, int m) {
        cells = new Cell[4];
        cells[0] = new Cell(n, m);
        cells[1] = new Cell(n, m + 1);
        cells[2] = new Cell(n, m + 2);
        cells[3] = new Cell(n + 1, m + 1);
    }


}
class O extends Tetromino{

    public O(int n,int m){
        //cells=new Cell[4];
        cells[0]=new Cell(n,m);
        cells[1]=new Cell(n,m+1);
        cells[2]=new Cell(n+1,m);
        cells[3]=new Cell(n+1,m+1);
    }
}
class L extends Tetromino{
    public L(int n,int m){
        cells=new Cell[4];
        cells[0]=new Cell(n,m);
        cells[1]=new Cell(n+1,m);
        cells[2]=new Cell(n+2,m);
        cells[3]=new Cell(n+2,m+1);
    }
}
class Z extends Tetromino{
    public Z(int n,int m){
        cells=new Cell[4];
        cells[0]=new Cell(n,m);
        cells[1]=new Cell(n,m+1);
        cells[2]=new Cell(n+1,m+1);
        cells[3]=new Cell(n+1,m+2);
    }
}
class I extends Tetromino{
    public I(int n,int m){
        cells=new Cell[4];
        cells[0]=new Cell(n+1,m);
        cells[1]=new Cell(n+2,m);
        cells[2]=new Cell(n+3,m);
        cells[3]=new Cell(n+4,m);
    }
}
class S extends Tetromino{
    public S(int n,int m){
        cells=new Cell[4];
        cells[0]=new Cell(n,m+1);
        cells[1]=new Cell(n,m+2);
        cells[2]=new Cell(n+1,m);
        cells[3]=new Cell(n+1,m+1);
    }
}
class J extends Tetromino{
    public J(int n,int m){
        //cells=new Cell[4];
        cells[0]=new Cell(n,m+1);
        cells[1]=new Cell(n+1,m+1);
        cells[2]=new Cell(n+2,m+1);
        cells[3]=new Cell(n+2,m);
    }
}

//提取子类的共有点
class Tetromino{
    Cell[] cells;//对象数组？
    public Tetromino(){//父类无参构造
        cells=new Cell[4];//每次调用都新new了 Cell[4]
    }


    public void printInfo(){
        for (int i = 0; i <cells.length ; i++) {
            cells[i].printInfo();
        }
    }
}

